var canSelFstCategories = new Array();
var $;
_bx.push([function () {
    $ = jQuery;
    $("#categorySearch-keywords").keydown(function (b) {
        var a = window.event ? b.keyCode : b.which;
        if (a == "13" || a.toString() == "13") {
            searchCategory();
            return false;
        }
    });
    $("#categorySearch-submit").click(function () {
        searchCategory();
        return false;
    });
    $("#categoryItem").show();
} ]);
_bx.push(["/media/js/jquery-ui-1.8.7.custom.min__39082__.js",
function () {
    $ = jQuery;
    $(".tag").live("change",
    function () {
        changeTag($(this));
    });
    $(".selectData").live("click",
    function () {
        $this = $(this);
        $("#display" + $this.attr("key")).focus();
    });
    var a;
    $(".selectData a").live("click",
    function () {
        $this = $(this);
        var d = $this.attr("key");
        var c = $this.text();
        var e = $this.attr("value");
        if (e == "usedCategory") {
            return;
        }
        if (d == "category_secondCategory" && typeof (_icq.push) == "function") {
            _icq.push("fabu_category_cnt_" + e + "_" + jQuery("input[name=postToken]").attr("value"));
        }
        $("a.selected").removeClass("selected");
        $this.addClass("selected");
        $("#display" + d).val(c).blur();
        selectTag($(this), false, true);
        var b = $("#value" + d);
        b.val(e).blur();
        clearTimeout(a);
        changeTag(b);
        return false;
    });
    $(".selectBox").live("change",
    function () {
        var d = $(this);
        var c = d.attr("key");
        var b = $("#value" + c);
        b.val(d.val());
        d.parents(".controls").find(".selectBox").css("color", "#333");
        if (!d.attr("readonly")) {
            clearTimeout(a);
            if (b.val()) {
                a = setTimeout('changeTag($("#value' + c + '"));', 500);
            }
        }
    }).live("keydown",
    function (g) {
        var f = $("#data" + $(this).attr("key"));
        if (f.is(":visible")) {
            $(this).autocomplete("disable");
            var d = $.ui.keyCode;
            var f = $("#data" + $(this).attr("key"));
            var c = f.find("a.hover").first();
            switch (g.keyCode) {
                case d.UP:
                    if (c.length) {
                        c.removeClass("hover");
                        var h = null;
                        f.find("a").each(function () {
                            if ($(this).attr("id") == c.attr("id")) {
                                if (h) {
                                    h.addClass("hover");
                                }
                                return false;
                            }
                            h = $(this);
                        });
                    } else {
                        f.find("a").last().addClass("hover");
                    }
                    return;
                case d.DOWN:
                    if (c.length) {
                        c.removeClass("hover");
                        var b = false;
                        f.find("a").each(function () {
                            if (b) {
                                $(this).addClass("hover");
                                return false;
                            }
                            if ($(this).attr("id") == c.attr("id")) {
                                b = true;
                            }
                        });
                    } else {
                        f.find("a").first().addClass("hover");
                    }
                    return;
                case d.ESCAPE:
                    selectTag($(this), false);
                    return;
                case d.ENTER:
                case d.NUMPAD_ENTER:
                    c.click();
                    return false;
            }
        }
        if ($(this).hasClass("form-input")) {
            selectTag($(this), false, true);
            $(this).autocomplete("enable");
        }
    }).live("focus",
    function () {
        clearTimeout(a);
        var c = $(this);
        c.parents(".controls").find(".selectBox").css("color", "#999");
        c.css("color", "#000");
        if (c.hasClass("selectStyle") || c.val() == "") {
            selectTag(c, true);
        }
        if (!c.attr("readonly")) {
            var b = "http://www.baixing.com/ajax/tag/autocomplete/?category=" + secondCategoryEnglishName + "&cityEnglishName=" + cityEnglishName + "&key=" + encodeURIComponent(c.attr("key"));
            $(".tag").each(function () {
                var e = $(this);
                var d = e.val();
                if (d && d != "其他") {
                    b += "&" + encodeURIComponent(e.attr("name")) + "=" + encodeURIComponent(d);
                }
            });
            $(this).autocomplete("option", "source", b);
        }
    }).live("click",
    function () {
        clearTimeout(a);
        selectTag($(this), true);
    }).live("blur",
    function () {
        var d = $(this);
        setTimeout('$("#' + d.attr("id") + '").autocomplete("close");', 300);
        selectTag(d, false);
        var c = d.attr("key");
        var b = $("#value" + c);
        if (!b.val()) {
            checkAutoComplete(d);
        }
        d.parents(".controls").find(".selectBox").css("color", "#333");
    });
    $("input, select, radio").live("blur",
    function () {
        generateTitle($(this));
    });
    $("input[type=checkbox]").live("change",
    function () {
        generateTitle($(this));
    });
    $(".selectData").live("mouseenter",
    function () {
        isOnSelect = true;
    }).live("mouseleave",
    function () {
        isOnSelect = false;
    });
} ]);
function checkAutoComplete(c) {
    $widget = c.autocomplete("widget");
    if ($widget[0].tagName.toLowerCase() == "ul") {
        var b = c.val().toLowerCase();
        var a = [];
        $widget.find("a").each(function () {
            var e = $(this).text().toLowerCase();
            var d = new RegExp("(^|\\s)" + b + "($|\\s)");
            if (e == b || d.exec(e)) {
                a.push($(this));
            }
        });
        if (a.length == 1) {
            a[0].mouseover().click();
        }
    }
}
var autoCompelteOn = false;
function openAutoComplete() {
    selectTag($(this), false);
    var b = $("ul.ui-autocomplete");
    var a = $(".tag_overlay");
    autoCompelteOn = true;
    setTimeout(function () {
        a.show().offset(b.offset()).width(b.width() + 15).height(b.height() + 15);
    },
    10);
}
function closeAutoComplete() {
    $(".tag_overlay").hide();
    autoCompelteOn = false;
}
function selectAutoComplete(f, d) {
    var b = $(this).attr("key");
    var a = $("#value" + b);
    var c = d.item.data[b.split("_")[0]];
    if (c) {
        a.attr("name", b.split("_")[0]);
        a.val(c.id);
        changeTag(a);
    }
}
function changeTag(e) {
    var a = "http://www.baixing.com/ajax/tag/select/?category=" + secondCategoryEnglishName + "&cityEnglishName=" + cityEnglishName;
    var d = e.val();
    var b = e.attr("name");
    a += "&key=" + encodeURIComponent(b) + "&value=" + encodeURIComponent(d);
    var c = "";
    $(".tag").each(function () {
        var g = $(this);
        var f = g.val();
        if (f && f != "其他") {
            c += "&" + encodeURIComponent(g.attr("name")) + "=" + encodeURIComponent(f);
        }
    });
    $.getJSON(a + c,
    function (g) {
        for (type in g) {
            try {
                if (type == "attributes") {
                    for (b in g[type]) {
                        setAttributeValue(b, g[type][b]);
                    }
                } else {
                    $controlBox = $("#meta" + type);
                    $controlBox.html(g[type]);
                }
            } catch (f) { }
        }
    });
}
function getAttributeValue(a) {
    $control = $('*[name="' + a + '"], *[name="' + a + '[]"], *[name="' + a + 'Select"]');
    if (!$control.length) {
        return "";
    }
    var b = "";
    if ($control[0].type.toLowerCase() == "radio") {
        b = $control.filter(":checked").val();
    } else {
        if ($control[0].type.toLowerCase() == "checkbox") {
            $control.filter(":checked").each(function () {
                b += $(this).val();
            });
        } else {
            $control = $control.last();
            if ($control.hasClass("selectInput")) {
                $control = $("#display" + a);
                b = $control.val();
            } else {
                if ($control[0].tagName.toLowerCase() == "select") {
                    b = $control.find("option:selected").text();
                } else {
                    b = $control.val();
                }
            }
            if (b == "其他" || ($control.attr("placeholder") && b == $control.attr("placeholder")) || ($control.attr("unit") && b == $control.attr("unit"))) {
                b = "";
            }
        }
    }
    return (!b || b.indexOf("请选择") != -1) ? "" : b;
}
function setAttributeValue(b, d, c) {
    $control = $('*[name="' + b + '"], *[name="' + b + '[]"]');
    if (!$control.length) {
        if (!c) {
            return false;
        }
        $val = $("textarea[name=description]").val();
        if ($val.indexOf(b + ": ") != -1) {
            $("textarea[name=description]").val($val.replace(new RegExp(b + ": .*"), b + ": " + d));
        } else {
            $("textarea[name=description]").val($val + "\n" + b + ": " + d);
        }
        return true;
    }
    if ($control[0].tagName.toLowerCase() == "select") {
        $control.find('option[value="' + d + '"]').attr("selected", true);
    } else {
        if ($control.attr("type").toLowerCase() == "radio") {
            $control.filter('input[value="' + d + '"]').attr("checked", true);
        } else {
            if ($control.attr("type").toLowerCase() == "checkbox") {
                var a = d.split(",");
                for (i = 0; i < a.length; i++) {
                    $control.find('input[value="' + a[i] + '"]').attr("checked", true);
                }
            } else {
                $control.val(d);
            }
        }
    }
    return true;
}
var isOnSelect = false;
function selectTag(e, b, d) {
    if (autoCompelteOn) {
        return;
    }
    var c = $("#data" + e.attr("key"));
    var a = $(".tag_overlay");
    if (b) {
        $(".selectData").hide();
        $("#categorySelector .tabMenu").hide();
        $(".selects-seprator").hide();
        if (parseInt(c.attr("tags")) <= 0) {
            return;
        }
        c.show();
        c.find("span").show();
        c.parent().show();
        setTimeout(function () {
            a.show().offset(c.offset()).width(c.width() + 15).height(c.height() + 15);
        },
        10);
    } else {
        if (!isOnSelect || d) {
            c.hide();
            a.hide();
        }
    }
}
var autoTitle;
function generateTitle(c) {
    if (!autoTitle || !c.attr("key") || autoTitle.indexOf("{" + c.attr("key") + "}") == -1) {
        return false;
    }
    var a = autoTitle.match(/\{([^\}\{]+)\}/g);
    if (!a) {
        return false;
    }
    var d = autoTitle;
    var b = "";
    for (i = 0; i < a.length; i++) {
        b = getAttributeValue(a[i].replace(/[\{\}]/g, ""));
        d = d.replace(new RegExp(a[i]), b);
    }
    if (d.length > 25) {
        d = d.substr(0, 22) + "...";
    }
    $("input[name=title]").val(d.replace(/[\{\}]/g, ""));
    return true;
}
function searchCategory() {
    var d = $("#categorySearch-res");
    var a = $("#categorySearch-nores");
    var c = $("#categorySearch-keywords").val();
    if (!c) {
        return false;
    }
    a.hide();
    d.html('<img style="margin:3px 0px 0px 3px;" src="http://static.baixing.net/images/bar.gif" /> 正在查找，请稍候').parent().show();
    var b = "/fabu/postsearch/?keyword=" + encodeURIComponent(c) + "&category=" + $("#category").val() + (isBianji ? "&adId=" + adId + "&r=" + Math.floor(Math.random() * 100000) : "");
    $.get(b,
    function (f) {
        var e = $("#categorySearch-suggestion");
        if (f) {
            e.html("大家通常把“" + c + "”相关的信息发布到以下类目：").show();
            d.html(f).parent().show();
        } else {
            e.hide();
            d.parent().hide();
            a.html("非常抱歉！暂时找不到对应“" + c + "”的类目<br />修改关键词再试试？").show();
        }
    });
}
function selectCategory(b) {
    var a = $("#valuecategory_firstCategory");
    a.val(b).blur();
    changeTag(a);
    _icq.push("发布_常用类目选择");
    return false;
}
var formStr = "";
function formVal() {
    formStr = "";
    var b = document.getElementById("postForm");
    for (var a = b.elements.length - 1; a >= 0; a--) {
        $formItem = $(b.elements[a]);
        if ($formItem[0].type != "text" || $formItem.hasClass("selectBox") || !$formItem[0].name || !(value = getAttributeValue($formItem[0].name)) || ($formItem[0].tagName.toLowerCase() != "input" && $formItem[0].tagName.toLowerCase() != "textarea")) {
            continue;
        }
        formStr += $formItem[0].name + "=" + value + "&";
    }
}
function showAttribute() {
    $("#setAttribute").html('<img style="margin-left:165px;" src="http://static.baixing.net/images/bar.gif" /> 正在加载，请稍候').show();
    if ($("#jobItem")) {
        $("#jobItem").remove();
    }
    var b = location.search.replace(/adId=[^\&]*\&?/, "").replace(/category=[^\&]*\&?/, "").replace(/src=[^\&]*\&?/, "").replace(/\&$/, "").replace(/^[\&\?]/, "");
    var a = "/fabu/metahtml/?city=" + cityEnglishName + "&category=" + $("#category").val() + (isBianji ? "&adId=" + adId : "") + "&" + b + "&" + formStr + "r=" + Math.floor(Math.random() * 100000);
    document.getElementById("saveBtn").style.display = "block";
    jQuery.getJSON(a,
    function (f) {
        var c = new RegExp("(^|&)category=([^&]*)(&|$)");
        var e = a.substr(1).match(c);
        if (e == null || $("#category").val() != (unescape(e[2]))) {
            return;
        }
        metaHtml = f.att + f.imgAttr;
        wantedMetaHtml = f.wantedAtt + f.imgAttr;
        $("#gongqiu").html(f.gq).show();
        $("#setAttribute").html(jQuery("input:radio[name=wanted]:checked").val() == "1" ? wantedMetaHtml : metaHtml).css("display", "block");
        if (f.limit) {
            $("#categoryLimitTips").show().find("div").html(f.limit);
        }
        if (f.banned != null) {
            $("#modal-banned .modal-content").html(f.banned);
            $("#modal-banned").modal({
                show: true,
                backdrop: "static",
                keyboard: false
            });
        }
        autoTitle = f.autoTitle;
        bindFormEvent();
        var d = $("#categorySearch input").val();
        if (!d) {
            d = getQueryString("title");
        }
        if (d && $("input[name=title]").val() == "") {
            $("input[name=title]").val(d);
        }
    });
    return false;
}
function getQueryString(a) {
    if (location.href.indexOf("?") == -1 || location.href.indexOf(a + "=") == -1) {
        return "";
    }
    var g = location.href.substring(location.href.indexOf("?") + 1);
    var d = g.split("&");
    var f, e, c;
    for (var b = 0; b < d.length; b++) {
        f = d[b].indexOf("=");
        if (f == -1) {
            continue;
        }
        e = d[b].substring(0, f);
        c = d[b].substring(f + 1);
        if (e == a) {
            return unescape(c.replace(/\+/g, " "));
        }
    }
    return "";
}
function bindFormEvent() {
    $("#postSubmit").next("span.errMsg").remove();
    $("input[name=wanted]").unbind("click").click(function () {
        $("#setAttribute").html($(this).val() == 1 ? wantedMetaHtml : metaHtml);
    });
    checkDingPromot();
    $(".item").unbind("click").click(function () {
        checkDingPromot();
    });
    var b = document.getElementById("postForm");
    var c;
    for (var a = 0; a < b.elements.length; a++) {
        c = $(b.elements[a]);
        if (c.attr("type") != "hidden" && c.attr("id") != "postSubmit") {
            c.unbind("blur").unbind("focus").blur(function () {
                var d = $(this);
                generateTitle(d);
                if (d.hasClass("selectBox")) {
                    return false;
                }
                $("#tips" + d.attr("name")).hide();
                d.val($.trim(d.val()));
                if (d.val() && (!d.attr("unit") || d.val() != d.attr("unit"))) {
                    formValids(d, false);
                }
                if (d.attr("placeholder")) {
                    if (d.val() == "" || (d.attr("unit") && d.val() == d.attr("unit"))) {
                        d.val(d.attr("placeholder")).addClass("placeholder");
                    }
                }
            }).focus(function () {
                var d = $(this);
                $("#" + $(this).attr("name") + "Check").remove();
                $("#tips" + $(this).attr("name")).show();
                $("#postSubmit").next("span.errMsg").remove();
                if (d.attr("placeholder")) {
                    if (d.val() == d.attr("placeholder")) {
                        d.removeClass("placeholder").val(d.attr("unit") ? d.attr("unit") : "");
                    }
                }
            }).click(function () {
                if ($(this).attr("type") == "checkbox" || $(this).attr("type") == "radio") {
                    $(this).focus();
                }
            }).keypress(function (f) {
                var d = window.event ? f.keyCode : f.which;
                if (d.toString() == "13" && $(this)[0].tagName.toLowerCase() != "textarea") {
                    return false;
                }
            });
            if (c.attr("type") == "checkbox") {
                c.focus(function () {
                    $(this).parents(".p-line").find("cite").remove();
                });
            }
            if (c.attr("placeholder")) {
                if (c.val() == "" || (c.attr("unit") && c.val() == c.attr("unit"))) {
                    c.val(c.attr("placeholder")).addClass("placeholder");
                }
            }
        }
    }
    $("input[type=checkbox]").unbind("change").change(function () {
        var d = $(this).attr("name");
        var e = $(this).attr("maxselectnumber");
        if ($('input[name="' + d + '"]:checked').length > e) {
            $(this).attr("checked", false);
            alert("最多可以选择  " + e + " 项");
        }
    });
    _bx.push(["/media/js/jquery.autoresize__32698__.js",
    function () {
        $("#postForm textarea").autoResize({
            limit: 300
        });
    } ]);
    b.onsubmit = function () {
        var e = $("#postSubmit");
        e.next("span.errMsg").remove();
        e.hide();
        e.after('<span id="postWaiting"><img src="http://static.baixing.net/images/bar.gif" /> 正在提交，请稍候</span>');
        var d = formCheck(this, e);
        e.show();
        e.parent().find("#postWaiting").remove();
        return d;
    };
}
function formCheck(b, d) {
    errorItem = null;
    for (var a = b.elements.length - 1; a >= 0; a--) {
        var c = $(b.elements[a]);
        formValids(c, true);
    }
    $(".checkbox-group").each(function () {
        if ($(this).find('input[type="checkbox"].required').length > 0 && $(this).find('input[type="checkbox"].required:checked').length <= 0 && $(this).parent().find(".error").length <= 0) {
            $('<cite class="red p-note error" style="display:block;padding-top:10px;padding-left:130px;">请至少选择一项内容</cite>').appendTo($(this).parent());
        }
    });
    if (imageUploading <= 0 && !errorItem && checkNewUser() && (!isDing || serviceCheck(b))) {
        return true;
    }
    if (errorItem) {
        d.after('<span class="errMsg" style="display:inline;margin-left:5px">表单填写有错误，请检查</span>');
    } else {
        if (imageUploading > 0) {
            d.after('<span class="errMsg" style="display:inline;margin-left:5px">图片正在上传中，请等待一会再发，或者取消上传后发布</span>');
        }
    }
    return false;
}
function serviceCheck(b) {
    var a = true;
    jQuery.ajax({
        cache: false,
        type: "POST",
        data: jQuery(b).serializeArray(),
        dataType: "json",
        url: jQuery(b).attr("action").replace("post", "servicecheck"),
        async: false,
        success: function (c) {
            switch (c.type) {
                case "error":
                    alert(c.msg);
                    a = false;
                    break;
                case "notice":
                    a = confirm(c.msg + "\n确认编辑信息？");
                    break;
            }
        }
    });
    return a;
}
var errorItem = null;
var mobBindText = "此手机已被其他用户验证";
function formValids(formItem, submit) {
    var error;
    if (formItem.attr("placeholder") && formItem.val() == formItem.attr("placeholder")) {
        formItem.val("");
    }
    try {
        if (submit && formItem.attr("name") == "contact") {
            error = contactValid(formItem.val());
            if (error == mobBindText) {
                errorItem = formItem;
                return showUserBox("login", formItem.val(), error, 1, false);
            }
        } else {
            error = eval(formItem.attr("name") + "Valid")(formItem.val());
        }
    } catch (e) {
        switch (formItem.attr("type")) {
            case "checkbox":
            case "radio":
                error = $("input[name=" + formItem.attr("name") + "]:checked").length <= 0;
                break;
            default:
                error = (formItem.val() == "" || formItem.val() == formItem.attr("unit"));
                break;
        }
    }
    if (!formItem.hasClass("required")) {
        error = null;
    }
    if (!error) {
        error = (formItem.attr("maxlength") > 0 && formItem.attr("maxlength") < 1000 && formItem.val().length > formItem.attr("maxlength")) ? "长度不能超过" + formItem.attr("maxlength") + "个字" : false;
    }
    if (!error) {
        try {
            error = mktValid(formItem.attr("name"), formItem.val());
        } catch (e) { }
    }
    if (error) {
        errorItem = formItem;
        return formItemShowError(formItem, error);
    } else {
        return formItemShowOK(formItem);
    }
}
function formItemShowError(c, a) {
    var b = $("#" + c.attr("name") + "Check");
    if (!b.length) {
        b = createCheckDiv(c);
    }
    if (!b) {
        return;
    }
    if (a == true) {
        a = "请" + ((c.attr("type") == "text" && !c.hasClass("tag")) ? "填写" : "选择") + c.attr("belong");
    }
    b.html(a).show(5).css("*display", "inline-block");
    $(window).scrollTop(b.offset().top - 20);
}
function formItemShowOK(a) {
    return true;
}
function createCheckDiv(b) {
    if (!b || !b.attr("name")) {
        return false;
    }
    if ($(b.parents("div.meta")[0]).find("div.checkDiv").length > 0) {
        return false;
    }
    var a = b.attr("name");
    return $('<cite class="red p-note error" id="' + a.replace(/([\[\]])/ig, "") + 'Check"></cite>').appendTo(b.parents("div.p-line")[0]);
}
function contactValid(b) {
    var c = stringTrim(b);
    if (secondCategoryEnglishName != "shouji") {
        if (c.length < 6) {
            return "请填写有效的联系方式，手机/电话或QQ";
        }
    } else {
        if (!isTel(c) && !isMobile(c) && !is400Tel(c)) {
            return "请按照格式填写，如138********，021-5432****或5432****，400*******";
        }
    }
    if (!isBianji) {
        var a = $.parseJSON($.ajax({
            url: "http://www.baixing.com/ajax/Valid/isVerifyMobileHoster?t=" + (+new Date().getTime()) + "&mobile=" + c,
            async: false
        }).responseText);
        if (!a.success) {
            return mobBindText;
        }
    }
    return false;
}
function isTel(a) {
    if (a.length < 7 || a.length > 18) {
        return false;
    }
    return patternMatch(a, /^(0?\d{2,3}-)?\d{7,8}(-\d{3,4})?$/);
}
function isMobile(a) {
    if (a.length != 11) {
        return false;
    }
    return patternMatch(a, /^(1(3|4|5|8))\d{9}$/);
}
function is400Tel(a) {
    var b = (a.split("-")).join("");
    if (b.length != 10) {
        return false;
    }
    return patternMatch(b, /^400\d{7}$/);
}
function patternMatch(a, b) {
    return b.test(a);
}
function descriptionValid(b) {
    var c = stringTrim(b);
    var a = 0;
    for (i = 0; i < c.length; i++) {
        a += c.charCodeAt(i) < 0 || c.charCodeAt(i) > 255 ? 3 : 1;
    }
    if (a > 5000) {
        return "内容太多了，精简一点吧";
    }
    return false;
}
function stringTrim(a) {
    return a.replace(/(^\s*)|(\s*$)/g, "");
}
function checkDingPromot() {
    var c = $("input[name=发布人][value=商家], input[name=发布人][value=经纪人], input[name=发布人][value=网店]");
    var b = false;
    for (var a = 0; a < c.size(); a++) {
        if (c[a].checked) {
            b = true;
            break;
        }
    }
    b = (c.is("input")) ? b : false;
    if (firstCategoryEnglishName == "fuwu" || firstCategoryEnglishName == "jiaoyupeixun" || b) {
        $("#promot").show();
        $("#promot input").removeAttr("disabled");
        $(".freeT").hide();
    } else {
        $("#promot").hide();
        $("#promot input").attr("disabled", "disabled");
        $(".freeT").show();
    }
}
function checkNewUser() {
    var b = /1(3|4|5|8)[\d]{9}/;
    var a = b.exec($("input[name=contact]").val());
    if (readCookie("__u") != null) {
        if (a == null) {
            return true;
        }
        if (contactValid(a[0]) != mobBindText) {
            return true;
        }
    }
    Ajax.auth(function () {
        $(".form-submit").click();
    },
    null, a == null ? "" : a[0]);
    return false;
}
_bx.push([function () {
    $("#imagesUl img").live("click",
    function () {
        var c = $(this).parent();
        var d = $("#imagesUl li:first");
        var b = d.position().left - c.position().left;
        var a = d.position().top - c.position().top;
        if (b == 0) {
            return;
        }
        c.css("position", "relative").css("top", "-20px");
        c.animate({
            left: b - 20,
            top: a - 20
        },
        800,
        function () {
            c.css("left", "0").css("top", "0").parent().prepend(c);
        });
    });
} ]);
function setLiImg(a) {
    $("#imgupload .tipMsg").html("").hide();
    $('<li id="li_' + a + '"><img src="http://static.baixing.net/images/css/global/img_loader.gif" class="imgUpload" width="64" height="64" /></li>').appendTo($("#imagesUl"));
    $("#imagesTable").show();
    imageUploading++;
}
function increaseImgNumber(a) {
    var b = $("#imgHint");
    b.val(parseInt(b.val()) + a);
}
function RemovePreview(a) {
    imageUploading--;
    $("#uploadTd iframe").show();
    if ($(a).parent().parent().attr("id") == "imagesUl") {
        $(a).parent().remove();
    } else {
        $(a).parent().parent().remove();
    }
    try {
        uploader.refresh();
    } catch (b) { }
}
function setLiImgError(c, a, b) {
    $("#li_" + c).html('<div class="imgUpError">' + b + '</div><a href="javascript:void(0)" onclick="RemovePreview(this)">取消</a>');
    increaseImgNumber(-1);
    imageUploading--;
}
function insertImg(e, d) {
    var a = $("#imagesUl li").length;
    if (a > imageLimit) {
        $("#imgupload .tipMsg").html('<span style="color:red">非常抱歉！最多只能上传' + imageLimit + "张照片</span>").show();
        $("#li_" + e).remove();
        return;
    } else {
        if (a == imageLimit) {
            $("#uploadTd iframe").hide();
        }
    }
    var c = d.replace(/\.(\w+)$/, "_sq.$1");
    var b = ('<input type="hidden" name="image[]" value="' + d + '" />\n					<img src="' + c + '" width="64" height="64" class="imgBorderBeta" />\n					<span class="imgBeta">\n						<img width="10" height="8" src="http://static.baixing.net/images/post/dui.gif" align="absmiddle" /> 成功\n						<a href="javascript:void(0)" onclick="RemovePreview(this)">\n							<img src="http://static.baixing.net/images/post/laji.gif" align="absmiddle" width="10" height="10" alt="删除这张图片" border="0" />\n						</a>\n					</span>\n					<div class="blank10"></div>');
    $("#" + e).parent().remove();
    if (!$("li_" + e)) {
        return;
    }
    $("#li_" + e).html(b);
    increaseImgNumber(+1);
    $("#imagesTable").show();
    imageUploading--;
}
function addIframe(a) {
    _bx.push(function () {
        $('<div style="display:none"><iframe name="' + a + '" id="' + a + '"></iframe></div>').appendTo("#iframes");
        $("#imageIframeLoader").remove();
        return;
    });
}
_bx.push(["/media/js/swfupload_beta/swfupload__33011__.js",
function () {
    function a() {
        return secondCategoryEnglishName == "riyongpin";
    }
    var b = jQuery.browser.msie ? Math.ceil(Math.random() * 100) % 100 : "1";
    var l = function (r) {
        return jQuery("#thumb_" + r.id);
    };
    var q = function () {
        jQuery("#imagesUl").show();
    };
    var h = function () {
        this.customSettings.loadingTimeout = setTimeout(function () {
            failOver();
        },
        10 * 1000);
    };
    var f = function () {
        if (jsClicked) {
            jQuery("#uploader").remove();
            return;
        }
        clearTimeout(this.customSettings.loadingTimeout);
        jQuery("#jsupload").hide().html("");
        jQuery("#uploader").css("position", "static").css("top", "0");
        q();
        jQuery("#uploader small").fadeIn();
        jQuery("#imgupload .tipMsg").html('<span style="color:green">最多可上传' + imageLimit + "张照片，每张照片不超过10M</span>").show();
    };
    var k = function () {
        failOver();
    };
    var m = function () {
        jQuery("#imgupload .tipMsg").html("");
        this.setUploadURL(a() ? "http://v0.api.upyun.com/" + img_space + "/" : "http://www.baixing.com/image_upload/?s");
        if (a()) {
            this.setPostParams({
                policy: img_policy,
                signature: img_signature
            });
        }
    };
    var j = function (r, s) {
        if (s > 0) {
            if (this.support.imageResize) {
                this.startResizedUpload(this.getFile(0).ID, this.customSettings.thumbnail_width, this.customSettings.thumbnail_height, SWFUpload.RESIZE_ENCODING.JPEG, this.customSettings.thumbnail_quality, false);
            } else {
                this.startUpload();
            }
        }
    };
    var o = function (r) {
        if (jQuery("#imagesUl li").length >= imageLimit) {
            jQuery("#imgupload .tipMsg").html('<span style="color:red">非常抱歉！最多只能上传' + imageLimit + "张照片</span>").show();
            return;
        }
        jQuery("#imagesUl").append(jQuery('<li><img title="点击设为封面" id="thumb_' + r.id + '" src="http://static.baixing.net/images/css/global/img_loader.gif" width="64" height="64" class="imgBorderBeta" />\n			<span class="imgBeta">正在上传</span><div class="tips hide"><div class="tips-text">点击设为封面</div></div></li>'));
        imageUploading++;
    };
    var n = function (r, t, s) {
        jQuery("#imgupload .tipMsg").html('<span style="color:red">非常抱歉！最多只能上传' + imageLimit + "张照片，每张照片不超过10M</span>").show();
    };
    var c = function (s) {
        swfuTimer = new Date().getTime();
        var r = l(s);
        r.attr("src", "http://static.baixing.net/images/css/global/img_loader.gif").next().html('<a href="javascript:void(0)" onclick="cancelUpload(\'' + s.id + "', this)\">取消</a>");
    };
    var d = function (s, u) {
        var t = Math.ceil((u / s.size) * 100);
        var r = l(s);
        r.find(".number").val(t < 100 ? t + "%" : "处理中…");
    };
    var g = function (u, t) {
        var s = jQuery.parseJSON(t);
        if (!s) {
            p(u, 101, "Result is null");
            return false;
        }
        swfuTimer = new Date().getTime() - swfuTimer;
        if (swfuTimer >= 30000 || swfuTimer <= 0 || Math.floor(Math.random() * 10) == 0) {
            _gaq.push(["_trackEvent", "ImgUpload" + (swfuTimer < 30000 && swfuTimer > 0 ? "" : "Fail"), "SWF", a() ? "UPYUN" : "SELF", swfuTimer]);
        }
        d(u, u.size);
        var r = l(u);
        r.attr("src", a() ? "http://img" + (s.url.charCodeAt(1) % 3 + 4) + ".baixing.net" + s.url + "_sq" : s.url.replace(/\.(\w+)$/, "_sq.$1")).addClass("uploaded").next().attr("title", "点击删除这张照片").html('<img width="10" height="8" src="http://static.baixing.net/images/post/dui.gif" align="absmiddle" /> 成功 \n				<a href="javascript:void(0)" onclick="cancelUpload(\'' + u.id + '\', this)">\n					<img src="http://static.baixing.net/images/post/laji.gif" align="absmiddle" width="10" height="10" alt="删除这张图片" border="0"/>\n				</a>').parent().prepend('<input type="hidden" name="image[]" value="' + s.url + '" />');
        imageUploading--;
        $(".container").length && $(".container").height("auto");
    };
    var e = function (r) {
        if (this.getStats().files_queued > 0) {
            if (this.support.imageResize) {
                this.startResizedUpload(this.getFile(0).ID, this.customSettings.thumbnail_width, this.customSettings.thumbnail_height, SWFUpload.RESIZE_ENCODING.JPEG, this.customSettings.thumbnail_quality, false);
            } else {
                this.startUpload();
            }
        } else {
            _bx.push(function () {
                jQuery("#imagesUl li").hover(function () {
                    $(this).find(".tips").show();
                },
                function () {
                    $(this).find(".tips").hide();
                });
            });
        }
    };
    var p = function (r, t, s) {
        imageUploading--;
    };
    SWFUpload.onload = function () {
        var r = {
            flash_url: "http://static.baixing.net/media/js/swfupload_beta/swfupload__27511__.swf?v=" + b,
            flash9_url: "http://static.baixing.net/media/js/swfupload_beta/swfupload_fp9__27511__.swf?v=" + b,
            upload_url: "http://www.baixing.com/image_upload/?s",
            custom_settings: {
                thumbnail_height: 800,
                thumbnail_width: 800,
                thumbnail_quality: 75
            },
            prevent_swf_caching: false,
            file_post_name: "file",
            file_size_limit: "10 MB",
            file_types: "*.jpg;*.jpeg;*.png;*.gif",
            file_types_description: "Web Image Files",
            file_upload_limit: 0,
            button_image_url: "http://static.baixing.net/media/js/swfupload_beta/btn_bg.v2.png",
            button_placeholder_id: "placeholder",
            button_width: 230,
            button_height: 25,
            button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
            button_cursor: SWFUpload.CURSOR.HAND,
            swfupload_loaded_handler: f,
            file_queued_handler: o,
            file_queue_error_handler: n,
            file_dialog_start_handler: m,
            file_dialog_complete_handler: j,
            upload_start_handler: c,
            upload_progress_handler: d,
            upload_error_handler: p,
            upload_success_handler: g,
            upload_complete_handler: e,
            swfupload_preload_handler: h,
            swfupload_load_failed_handler: k,
            debug: false
        };
        swfu = new SWFUpload(r);
    };
    swfobject.addDomLoadEvent(function () {
        if (typeof (SWFUpload.onload) === "function" && swfupload) {
            SWFUpload.onload.call(window);
        }
    });
} ]);